package com.maxatime.service.impl;

import com.maxatime.dao.ExamMapper;
import com.maxatime.dao.StudentMessageMapper;
import com.maxatime.exception.PhoenixException;
import com.maxatime.pojo.*;
import com.maxatime.service.StudentMessageService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @author Mr.Zhao
 * @title: StudentMessageServiceImpl
 * @projectName phoenix
 * @description: TODO
 * @date 2021/7/16 8:37
 */
@Service
public class StudentMessageServiceImpl implements StudentMessageService {
    Logger log = LogManager.getLogger();


    @Autowired
    private StudentMessageMapper studentMessageMapper;
    @Autowired
    private ExamMapper examMapper;


    @Override
    public Integer studentDelete(int studentId) {
        return studentMessageMapper.studentDelete(studentId);
    }

    @Override
    public List<StudentMessage> studentMess(String studentName, String mobile, String sex, Integer age, String idNum) {
        return studentMessageMapper.studentMess(studentName,mobile,sex,age,idNum);
    }

    @Override
    public StudentMessage updateView(int studentId) {
        return studentMessageMapper.updateView(studentId);
    }

    @Override
    public List<Provinces> provinces() {
        return studentMessageMapper.provinces();
    }

    @Override
    public List<Cities> cities() {
        return studentMessageMapper.cities();
    }

    @Override
    public List<Areas> areas() {
        return studentMessageMapper.areas();
    }

    @Override
    public Integer updateStu(StudentMessage stu) throws PhoenixException {
        try {
            return studentMessageMapper.updateByPrimaryKeySelective(stu);
        }catch (Exception e){

             log.error("studentMessageMapper.updateByPrimaryKeySelective:::"+stu);
             log.error("studentMessageMapper.updateByPrimaryKeySelective:::"+e.getMessage());
           throw new PhoenixException("9999","修改失败");
        }

    }

    @Override
    public Integer insertStu(StudentMessage stu) throws PhoenixException {
        try{

            return studentMessageMapper.insertSelective(stu);
        }catch (Exception e){
            log.error("studentMessageMapper.insertSelective:::"+stu);
            log.error("studentMessageMapper.insertSelective:::"+e.getMessage());
            throw  new PhoenixException("99999","添加失败");
        }


    }

    @Override
    public Integer deleteList(List<Integer> list) {
        return studentMessageMapper.deleteList(list);
    }

    @Override
    public List<StudentMessage> studentMessdd() {
        return studentMessageMapper.studentMessdd();
    }

    @Override
    public List<StudentMessage> stuexport() {
        return studentMessageMapper.stuexport();
    }

    @Override
    public void inse(List<StudentMessage> readResult) {
           studentMessageMapper.inse(readResult);
    }

    @Override
    public List<Exam> listss() {
        return examMapper.listss();
    }


}
